package {
    import flash.net.NetConnection;
    import flash.net.ObjectEncoding;
    import flash.net.Responder;
    import flash.utils.*;
    
    public class auth {
	    [Bindable]
	    public var session_id:String;
	    
	    private var session_obj:Object = null;
	    private var con:NetConnection;
	    private var responderSession:Responder;
        private var t1:uint;
        private var limit:int=50;
        private var count:int=0;
        private var time:int=2000;
        private var flg:Boolean=false;
        
        
	    private const GATEWAY_URL:String = "/amf_gateway.php";    
	    /**
	     *  初期データ読み込み
	     */
	    public function auth(ssid:String):void {
	      con = getCon();
	      session_id = ssid;
	    }
	    
	    /**
	     *   コネクション初期化
	     **/
	    public function getSession(onResultSession:*,onFault:*):void {
	      responderSession = new Responder(onResultSession, onFault);
	      con.call("SessionService.getSession", responderSession,session_id);
	    }
	    
	    /**
	     *   コネクション初期化
	     **/
	    private function getCon():NetConnection {
	      var time:Number = (new Date()).getTime();
	      var con:NetConnection = new NetConnection();
	      con.connect(GATEWAY_URL + "?time=" + time);
	      con.objectEncoding = ObjectEncoding.AMF3;
	      return con;
	    }
	    
	    /**
	     *   成功(SESSION)
	     **/
	     /*
	    public function onResultSession(etc:*):void {
	    
	      if (typeof etc == "object") {
	        session_obj = etc;
	      } else {
	        session_obj = null;
	      }
	    }
	    */
	    /**
	     *   失敗
	     **/
	    /*
	    private function onFault(etc:*):void {
	      session_obj = null;
	    }
	    
	    */
    }
}